import request from '@/utils/request'

// 获取方案库列表
export function getSchemeLibList() {
  return request.get('/schemeLibrary/list')
}

// 删除方案库
export function deleteSchemeLibrary(params: { id: string | number }) {
  return request.post('/schemeLibrary/delete', { params })
}

// 创建方案
export function createScheme(data: {
  name: string
  description: string
  url: string
  knowledgeId?: string | number
  llmId?: string | number
}) {
  return request.post('/schemeLibrary/create', { data })
}

// 获取方案详情
export function getSchemeDetail(params: { id: string | number }) {
  return request.get('/schemeLibrary/detail', { params })
}

// 获取方案列表
export function getSchemeList(params: {
  pageNum: number
  pageSize: number
  schemeName?: string
  startTime?: string | number
  endTime?: string | number
  categoryType?: string | number
  libraryType?: string | number
}) {
  return request.get('/doc/getSchemeList', { params })
}

// 更新方案名称
export function updateSchemeName(data: { id: string | number; shemeName: string }) {
  return request.post('/doc/updateSchemeName', { data })
}

// 删除方案
export function deleteScheme(data: { ids: string }) {
  return request.post('/doc/batchDeleteScheme', { data })
}

// 方案审核结果
export function getSchemeAuditResult(params: { id: string }) {
  return request.get('/auditRecord/list', { params })
}

// 生成方案
export function generateScheme(data: {
  schemeName: string
  categoryName: string
  categoryType: string
  path: string
  paramMap: any
  id?: string | number
}) {
  return request.post('/doc/schemeUpdate', { data })
}

// 知识库列表
export function getKnowledgeList() {
  return request.get('/schemeLibrary/KnowledgeList')
}

// 大模型列表
export function getModelList() {
  return request.get('/schemeLibrary/llmList')
}

// 方案审核列表
export function getSchemeAuditList(params: {
  pageNum: number
  pageSize: number
  schemeName?: string
  startTime?: string | number
  endTime?: string | number
  type: 1 | 2 // 1 人工审核 2 智能体审核
}) {
  return request.get('/schemeAudit/list', { params })
}

// 方案审核
export function getSchemeCategoryDetail(params: { id: string | number }) {
  return request.get('/schemeAudit/detail', { params })
}

// 获取模版参数列表
export function getTemplateParamList(params: { id: string | number }) {
  return request.get('/doc/getTemplateParamList', { params })
}

// 提交审核
export function submitAudit(data: {
  auditorId?: string | number
  schemeName?: string | number
  schemeId?: string
  remarks?: string
  type: 1 | 2 // 1 人工审核 2 智能体审核
  scheme?: any
}) {
  return request.post('/schemeAudit/submitAudit', { data })
}

// 审核
export function auditScheme(data: {
  schemeAuditId: string | number
  auditStatus: string | number
  type: 1 | 2 // 1 人工审核 2 智能体审核
  auditResult?: string
}) {
  return request.post('/auditRecord/create', { data })
}

// 根据方案id获取审核详情
export function getSchemeAuditDetail(params: { schemeId: string | number }) {
  return request.get('/schemeAudit/detailBySchemeId', { params })
}

// 方案生成导出
export const exportScheme = (params: { id: string | number }) => {
  return request.post('/schemeLibrary/export', { params, responseType: 'blob' })
}

// 方案审核删除
export const deleteSchemeAudit = (params: { id: string | number }) => {
  return request.post('/schemeAudit/delete', { params })
}

// 方案下载
export const downloadScheme = (data: { id: string | number; schemeName: string }) => {
  return request.post('/doc/download', { data, responseType: 'blob' })
}

// 下载审核报告
export const downloadAuditReport = (params: { id: string | number }) => {
  return request.get('/schemeAudit/downloadAuditResult', { params })
}
